<template>
  <view class="Box">
    <view v-if="type == 1" class="successBox">
      <view class="successIconBox">
        <u-icon color="#ffffff" name="checkmark" size="50"></u-icon>
      </view>
      <view class="successText">
        核销成功
      </view>
    </view>
    <view v-if="type == 2" class="failBox">
      <view class="failIconBox">
        <u-icon color="#ffffff" name="close" size="40"></u-icon>
      </view>
      <view class="failText">
        核销成功
      </view>
    </view>
    <view class="buttonBox" @click="continueClick">
      继续核销
    </view>
    <view class="buttonBox cancelBox" @click="cancelClick">
      返回
    </view>
  </view>
</template>

<script>
export default {
  data() {
    return {
      type: 1
    }
  },
  onLoad(data) {
    if (data.type) {
      this.type = data.type
    }

  },
  methods: {
    cancelClick() {
      uni.switchTab({
        url: '/pages/my/index'
      });
    },
    continueClick() {
      uni.scanCode({
        success: function (res) {
			uni.navigateTo({
			  url: "/" + res.path
			});
          console.log('条码类型：' + res.scanType);
          console.log('条码内容：' + res.result);
        }
      });
    }
  }
}
</script>

<style lang="scss">
.Box {
  display: flex;
  flex-direction: column;
  align-items: center;
}

.successBox {
  padding: 200rpx 0;

  .successIconBox {
    width: 116rpx;
    height: 116rpx;
    background-color: #28b78d;
    border-radius: 50%;
    display: flex;
    justify-content: center;
    align-items: center;
  }

  .successText {
    margin-top: 40rpx;
    font-weight: 800;
  }

}

.failBox {
  padding: 200rpx 0;

  .failIconBox {
    width: 116rpx;
    height: 116rpx;
    background-color: #ff5e5e;
    border-radius: 50%;
    display: flex;
    justify-content: center;
    align-items: center;
  }

  .failText {
    margin-top: 40rpx;
    font-weight: 800;
  }
}

.buttonBox {
  width: 384rpx;
  height: 84rpx;
  line-height: 84rpx;
  background: #4186f5;
  border-radius: 6px;
  text-align: center;
  margin-bottom: 36rpx;
  color: #fff;
}

.cancelBox {
  color: #4186f5;
  background-color: #fff;
  border: 2rpx solid #4186f5;
}
</style>
